package br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.home.info;

import br.edu.ufcg.lsd.wbis.ui.client.beans.UserInfo;
import br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.Updatable;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.gwtext.client.widgets.MessageBox;

/**
 * @author Renato Miceli
 */
public class UpdateInfoCallback implements AsyncCallback<UserInfo> {

	private final Updatable<UserInfo> parentPortlet;

	public UpdateInfoCallback(Updatable<UserInfo> parentPortlet) {
		this.parentPortlet = parentPortlet;
	}

	/**
	 * {@inheritDoc}
	 */
	public void onFailure(Throwable caught) {
		MessageBox.alert("Error", "The personal info could not be updated!");
	}

	/**
	 * {@inheritDoc}
	 */
	public void onSuccess(UserInfo result) {
		MessageBox.alert("Success", "Personal info updated!");
		this.parentPortlet.updateInfo(result);
	}

}
